﻿@{
    ViewBag.Title = "充值";
    ViewBag.PathToBtn = "/Charge/Index";
    ViewBag.TextBtn = "刷新";
    Layout = "~/Views/Shared/_Layout.cshtml";

}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                充值
            </div>
            <div class="panel-body">
                <div class="row">
                    @using (Html.BeginForm("Pay", "Charge", FormMethod.Post, new { id = "frmCreate", enctype = "multipart/form-data" }))
                    {
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)

                        <div class="col-lg-12">
                            <fieldset>
                                <div class="form-group col-md-12" style="text-align: center">
                                    <label>充值金额（只能充200元的整数倍）</label>
                                    <div class="input-group" style="text-align:center;width: 100%">
                                        <input type="number" class="form-control" name="money" id="money" maxlength="6" style="width: 40%;float:none"/>
                                    </div>
                                </div>
                                <div class="col-md-12" style="text-align: center">
                                    <button id="btnSave" type="submit" class="btn btn-primary">马上充值</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>

@section javascript{
    <script type="text/javascript">
        $(function () {
            $("#frmCreate").validate({
                rules: {
                    money: { required: true, min: 1, max: 100000, digits: true }
                },
                messages: {
                    money: { required: "请填写充值金额" }
                },
                submitHandler: function (form) {
                    var m = $("#money").val();
                    if (m % 200 == 0) {
                        form.submit();
                    } else {
                        alertify.error("充值金额必须为200元的整倍数");
                    }
                }
            });
        });
    </script>
}